import { defHttp } from "/@/utils/http/axios";
import { Modal } from "ant-design-vue";

export enum Api {
  treeGrid  = "/cmsMemberController/treeGrid",
  save      = "/cmsMemberController/save",
  delete    = "/cmsMemberController/delete",
  queryById = "/cmsMemberController/queryById",
  select    = "/cmsMemberController/treeSelect",
}

/**
 * 会员管理 - 列表
 * @param params
 */
export const treeGrid = async (params) => await defHttp.get({url: Api.treeGrid, params});

/**
 * 会员管理 - 通过ID获取数据
 * @param params
 */
export const queryById = (params) => defHttp.get({url: Api.queryById, params});

/**
 * 会员管理 - 保存或者更新
 * @param params
 */
export const save = (params) => {
  return defHttp.post({url: Api.save, params}, {isTransformResponse:false});
}

/**
 * 银行流水 - 通过ID删除数据
 * @param params
 */
export const del = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({ url: Api.delete, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess();
      });
    },
  });
}

